def map_number_to_range(input_val: int) -> int:
    if input_val < 2800 or input_val > 4200:
        return 255        # 表示错误
    elif 4050 < input_val < 4201:
        return 100
    elif input_val >= 3150:
        output = ((input_val - 3150) / (4050 - 3150)) * (100 - 20) + 20
        return int(output + 0.5)
    elif 2799 < input_val < 2851:
        return 1
    else:
        output = ((input_val - 2850) / (3150 - 2850)) * 19
        return int(output + 0.5)

# 示例：把所有待测值放在一个列表里
test_values = [2799, 2800, 2801, 2849, 2850,2900,3000, 3100,3149, 3150,3200,3300,3400,3500,3600,3700,3800,3900, 4050, 4051, 4199, 4200, 4201]

# 遍历并输出结果
for val in test_values:
    print(f"input: {val:5d} -> output: {map_number_to_range(val)}")